﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using MockPrjTeam2.Entity;
using MockPrjTeam2.DAO;

namespace MockPrjTeam2.Biz
{
    public class DirectorateBiz
    {
        private DirectorateDao directorateDao;

        public DirectorateBiz()
        {
            directorateDao = new DirectorateDao();
        }
        //method GetDirectorateByorgId()
        public DataTable GetDirectorateByorgId(int orgId)
        {
            return directorateDao.GetDirectorateByorgId(orgId);
        }
        //method GetDirectorateInacTive()
        public DataTable GetDirectorateInacTive(int idOrg)
        {
            return directorateDao.GetDirectorateInacTive(idOrg);
        }
        //method FilterOrganizationByLetters()
        public DataTable FilterDirectorateByLetters(string directorateName,int id,int flag)
        {
            return directorateDao.FilterDirectorateByLetters(directorateName,id,flag);
        }
        //method AddDirectorate
        public bool AddDirectorate(Directorate directorate)
        {
            return directorateDao.AddDirectorate(directorate);
        }
        //method GetDirectorateByDirectorareId()
        public Directorate GetDirectorateByDirectorareId(int directorateId)
        {
            Directorate directorate = new Directorate();
            DataTable dt = new DataTable();
            dt = directorateDao.GetDirectorateByDirectorareId(directorateId);
            foreach (DataRow dr in dt.Rows)
            {

                directorate.DirectorateName = dr["DirectorateName"].ToString();
                directorate.DirectorateShortDescription = dr["DirectorateShortDescription"].ToString();
                directorate.AddressLine1 = dr["AddressLine1"].ToString();
                directorate.AddressLine2 = dr["AddressLine2"].ToString();
                directorate.AddressLine3 = dr["AddressLine3"].ToString();
                directorate.CityTown = dr["CityTown"].ToString();
                directorate.County = dr["County"].ToString();
                directorate.PostCode = dr["PostCode"].ToString();
                directorate.BussinessTypeName = dr["BussinessTypeName"].ToString();
                directorate.SicCode = dr["SICCode"].ToString();
                directorate.ContactName = dr["ContactName"].ToString();
                directorate.DirectorateFullDescription = dr["DirectorateFullDescription"].ToString();
                directorate.PhoneNumber = dr["PhoneNumber"].ToString();
                directorate.Fax = dr["Fax"].ToString();
                directorate.Email = dr["Email"].ToString();
                directorate.WebAddress = dr["WebAddress"].ToString();
                directorate.CharityNumber = dr["CharityNumber"].ToString();
                directorate.CompanyNumber = dr["CompanyNumber"].ToString();
                directorate.CountryId = Convert.ToInt32(dr["CountryID"]);
                directorate.AddressId = Convert.ToInt32(dr["AddressID"]);
                directorate.BusinessTypeId = Convert.ToInt32(dr["BussinessTypeID"]);
                directorate.ContactId = Convert.ToInt32(dr["ContactID"]);
                directorate.OrgId = Convert.ToInt32(dr["OrgID"]);
                directorate.CountryName = dr["CountryName"].ToString();
                directorate.DirectorateId = Convert.ToInt32(dr["DirectorateID"]);
            }
            return directorate;
        }
         //method UpdateDirectorate()
        public bool UpdateDirectorate(Directorate directorate)
        {
            return directorateDao.UpdateDirectorate(directorate);
        }
         //method SetActiveDirectorate
        public bool SetActiveDirectorate(int directorateId, bool status)
        {
            return directorateDao.SetActiveDirectorate(directorateId, status);
        }
                //SetDirectorateInActive()
        public bool SetDirectorateInActive(int directorateId, bool status)
        {
            return directorateDao.SetDirectorateInActive(directorateId, status);
        }
        public DataTable FilterOrganizationByLetters(string directorateName)
        {
            return directorateDao.FilterOrganizationByLetters(directorateName);
        }
        public int CheckDirectorateNameExist(string dirName)
        {
            return directorateDao.CheckDirectorateNameExist(dirName);
        }
    }
}